package day04;

import java.util.Arrays;
import java.util.Base64;

public class Demo03 {
    public static void main(String[] args) {
        /*
         * Base64 编码
         */
        byte[] bytes = {0b01101110, (byte)0b10011000, (byte)0b11011101,
                0b01101111, 0b00001111};
        //编码
        String base64 = Base64.getEncoder().encodeToString(bytes);
        System.out.println(base64);
        //解码
        byte[] arr =  Base64.getDecoder().decode(base64);
        System.out.println(Arrays.equals(bytes, arr));
        for(byte b: arr){
            System.out.println(Integer.toBinaryString(b & 0xff));
        }

    }
}
